<?php
 header("Content-Type: text/html; charset=utf-8"); 
include ("conn.php");

if(isset($_POST['submit'])){

  $sql="insert into message (id,user,title,content,lastdate)" .
  		"values ('','$_POST[user]','$_POST[title]','$_POST[content]',now())";
  mysql_query($sql);
  echo  "<script language=\"javascript\">alert('添加成功');history.go(-1)</script>";

 }
 include("head.php");
?>
<SCRIPT language=javascript>
function CheckPost()
{
		if (myform.user.value=="")
		{
			alert("请填写用户名");
			myform.user.focus();
			return false;
		}
		if (myform.title.value.length<3)
		{
			alart("标题不能少于3个字符");
			myform.title.focus();
			return false;
		}
		if (myform.content.value=="")
		{
			alert("内容不能为空");
			myform.content.focus();
			return false;	
		}	
}
</script>
<form action="add.php " method="post" name="myform" onsubmit="return CheckPost();">
用户：<input type="text" size=10 name="user"/><br/>
标题：<input type="text" size=20 name="title"/><br/>
内容：<textarea name="content" cols="60" rows="9" ></textarea><br/>
<input type="submit" size="" name="submit" value="发布成功"/>
</form>
